package com.cloudcc.mobile.weight;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.cloudcc.mobile.R;

public class DialogUtilsZhuXiao {
	public static Dialog showWarn(Context context, String title,
			String content, final DialogOnClickListeners listener) {
		View view = LayoutInflater.from(context).inflate(R.layout.dialog_warnzhuxiao,
				null);
		final AlertDialog builder = new AlertDialog.Builder(context).create();
		builder.setCancelable(false);
		builder.setView(view);
		TextView dialogTitle = (TextView) view.findViewById(R.id.dialog_title);
		TextView dialogDesc = (TextView) view
				.findViewById(R.id.dialog_description);
		Button btnPositive = (Button) view.findViewById(R.id.dialog_positive);
		Button btnNegative = (Button) view.findViewById(R.id.dialog_negative);
		dialogTitle.setText(title);
		dialogDesc.setText(content);
		btnNegative.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				listener.onClickNegative(builder);
			}
		});
		btnPositive.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				listener.onClickPositive(builder);
			}
		});
		builder.show();
		return builder;
	}

	public static Dialog showAlert(Context context, String title,
			String content, final DialogOnClickListeners listener) {
		View view = LayoutInflater.from(context).inflate(R.layout.dialog_alert,
				null);
		final AlertDialog builder = new AlertDialog.Builder(context).create();
		builder.setCancelable(false);
		builder.setView(view);
		TextView dialogTitle = (TextView) view.findViewById(R.id.dialog_title);
		TextView dialogDesc = (TextView) view
				.findViewById(R.id.dialog_description);
		Button btnPositive = (Button) view.findViewById(R.id.dialog_positive);
		dialogTitle.setText(title);
		dialogDesc.setText(content);
		btnPositive.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				listener.onClickNegative(builder);
			}
		});
		builder.show();
		return builder;
	}
	
	public interface DialogOnClickListeners {

		public abstract void onClickPositive(Dialog dialog);

		public abstract void onClickNegative(Dialog dialog);

	}

}
